/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.biz.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.validation.constraints.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.List;

/**
 * @website https://eladmin.vip
 * @description /
 * @author Admin
 * @date 2023-02-17
 **/
@Entity
@Data
@Table(name="hj_lab")
public class Lab implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "`name`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "实验室名称")
    private String name;

    @Column(name = "`floor`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "楼层信息")
    private Integer floor;

    @Column(name = "`room_number`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "房间号")
    private String roomNumber;

    @Column(name = "`standard`")
    @ApiModelProperty(value = "实验室规范")
    private String standard;

    @Column(name = "`administrator`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "实验室管理员")
    private Integer administrator;

    @Column(name = "`created_at`")
    @CreationTimestamp
    @ApiModelProperty(value = "createdAt")
    private Timestamp createdAt;

    @Column(name = "`updated_at`")
    @UpdateTimestamp
    @ApiModelProperty(value = "updatedAt")
    private Timestamp updatedAt;

    @Column(name = "`is_deleted`")
    @ApiModelProperty(value = "是否删除")
    private Integer isDeleted;

    @Column(name = "`lab_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "实验室类型")
    private Integer labType;

    @Column(name = "`auth_number`")
    @ApiModelProperty(value = "授权数量")
    private Integer authNumber;

    @Column(name = "`admin_name`")
    @ApiModelProperty(value = "实验室管理员名称")
    private String adminName;

    @Column(name = "`pid`")
    @ApiModelProperty(value = "父实验室id")
    private Integer pid;

//    @OneToMany(mappedBy = "lab", cascade = CascadeType.ALL)
//    private List<Sensor> sensorList;

    public void copy(Lab source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
